package lab03.test13;

import java.sql.*;

public class Test13 {
    public static void main(String[] args) {
        //3+1
        Connection connection = null;
        Statement statement = null;
        ResultSet resultSet = null;

        String sql = "insert into" +
                            "t_student (stu_no,real_name,age,gender,department)"+
                            "values(1606101024,'wu',19,1,'IS')";

        try {
            Class.forName("com.mysql.jdbc.Driver");//加载驱动

            connection = DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/java_2017",
                    "root",
                    "251807680wmh"
            );

            statement = connection.createStatement();

            //resultset：查
            statement.execute(sql);

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            try {
                statement.close();
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }

        }
    }
}
